import { FormConfig } from '@/components'
import { Row } from '@/components/FTable/components/search'
import { configCurryFilter } from '@/dictionaries/filter'
import { BaseDto, Status } from '@/interfaces'
import { isTrue } from '@/utils/tools'
import dayjs from 'dayjs'
import { shallowRef } from 'vue'
import { CoupleState } from '../couple/uilts'
/*
 * @Description:
 * @Author: fhw
 * @Date: 2023-02-23 14:41:28
 */

export interface UserState extends BaseDto {
	/** 联系QQ */
	QQ?: string

	/** 访问时间 */
	accessDate?: string

	/** 用户头像 */
	avatar?: string

	/** 创建时间 */
	createDate?: string

	/** 个人介绍 */
	description?: string

	/** 邮箱 */
	email?: string

	/** 性别 1:男性，2:女性 */
	gender?: number

	/** id */
	id?: number

	/** 电话号码 */
	mobile?: string

	/** 密码 */
	password?: string

	/** 用户状态 10: 启用；20：禁用 */
	status?: number

	/** 更新时间 */
	updateDate?: string

	/** 用户名称 */
	username?: string
	coupleId?: number
	couple?: CoupleState
	/** 邀请码 */
	inviteCode?: string
	birthdayDate?: string
}
export const columns: F.TableColumns[] = [
	{
		title: 'id',
		key: 'id',
		dataIndex: 'id',
		align: 'center',
		width: 60
	},
	{
		title: '用户昵称',
		key: 'username',
		dataIndex: 'username',
		align: 'center',
		width: 200
	},
	{
		title: '邀请码',
		key: 'inviteCode',
		dataIndex: 'inviteCode',
		align: 'center',
		width: 200
	},
	{
		title: '头像',
		key: 'avatar',
		dataIndex: 'avatar',
		align: 'center',
		width: 100,
		customRender: ({ record }: F.RableSlotScope<UserState>) =>
			isTrue(record.avatar) ? (
				<a-image isAImage width={50} src={record.avatar} />
			) : '-',
	},
	{
		title: '性别',
		key: 'gender',
		dataIndex: 'gender',
		align: 'center',
		customRender: configCurryFilter('genderStatus'),
	},
	{
		title: '用户状态',
		key: 'status',
		dataIndex: 'status',
		align: 'center',
		customRender: configCurryFilter('status'),
	},
	{
		title: '生日',
		key: 'birthdayDate',
		dataIndex: 'birthdayDate',
		align: 'center',
		width: 200,
		customRender: ({ record }: F.RableSlotScope<UserState>) =>
			record.birthdayDate && dayjs(record.birthdayDate).format('YYYY-MM-DD'),
	},
	{
		title: '登陆时间',
		key: 'accessDate',
		dataIndex: 'accessDate',
		align: 'center',
		width: 200,
		customRender: ({ record }: F.RableSlotScope<UserState>) =>
			record.accessDate && dayjs(record.accessDate).format('YYYY-MM-DD HH:mm:ss'),
	},
	{
		title: '创建时间',
		key: 'createDate',
		dataIndex: 'createDate',
		align: 'center',
		width: 200,
		customRender: ({ record }: F.RableSlotScope<UserState>) =>
			record.createDate && dayjs(record.createDate).format('YYYY-MM-DD HH:mm:ss'),
	},
	{
		title: '更新时间',
		key: 'updateDate',
		dataIndex: 'updateDate',
		align: 'center',
		width: 200,
		customRender: ({ record }: F.RableSlotScope<UserState>) =>
			record.updateDate && dayjs(record.updateDate).format('YYYY-MM-DD HH:mm:ss'),
	},
	{
		title: '操作',
		dataIndex: 'action',
		key: 'action',
		align: 'center',
		slots: {
			customRender: 'actionRender',
		},
		width: 300,
		fixed: 'right',
	},
]
export const rows: Array<Row> = [
	{
		title: '用户昵称',
		key: 'nickname',
		component: 'a-input',
	},
	{
		title: '用户手机号',
		key: 'mobile',
		component: 'a-input',
	},
	{
		title: '用户状态',
		key: 'status',
		component: shallowRef(FormConfig),
		props: {
			prop: 'userStatus',
		},
	},
	{
		title: '用户审核状态',
		key: 'type',
		component: shallowRef(FormConfig),
		props: {
			prop: 'userType',
		},
	},
]